layui.use(['upload','table'],function(){
    var upload = layui.upload, table = layui.table;
    var exportData = [];
    /*@导入数据*/
    upload.render({
        elem: '#excel',
        url: '',
        accept: 'file',
        multiple: false,
        exts: 'xls|xlsx|csv',
        auto: false,
        bindAction: '#exportExcel',
        data: {
            ty: function(){
                return $('input[name="ty"]').val();
            },
            type: function(){
                return $('input[name="type"]').val();
            }
        },
        done: function(res, index, upload){
            if(res.code !== 1){
                layer.msg(res.msg, {icon: 5});
            }else{
                layer.msg(res.msg, {icon: 6});
                parent.location.reload();
            }
        },
    });
    /*@下载模版*/
    upload_excel = function(){
        var ty = $('input[name="ty"]').val();

        layer.confirm('确定下载', {icon: 3, title:'提示'}, function(index){
            $.get('/file/export_excel/download_csv',{ty:ty},function(data){
                console.log(data)
                if(data.code && data.code !== 1){
                    layer.msg(data.msg, {icon: 5})
                }else{
                    layer.close(index);
                    location.href="/file/export_excel/download_csv/ty/"+ty;
                }
            })
        })
    }

})